<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/public/header.jsp"%>
<html>
	<head>
		<title>公共费用明细</title>
	<script type="text/javascript">
	jQuery(document).ready(function() {
		$("#company_id").combotree({
				url:'<%=contextPath %>/springMVC/group/getSystemTypeTree?type=8',
				method:'POST',
				animate:true,
				lines:true,
				onChange:function(){
					doSearch();
				}
			});
		$("#type_id").combotree({
				url:'<%=contextPath %>/springMVC/group/getSystemTypeTree?type=9',
				method:'POST',
				animate:true,
				lines:true,
				onChange:function(){
					doSearch();
				}
			});
			
		jQuery("#user_name").keypress(function(e) { 
	    	// 回车键事件 
	     	if(e.which == 13) { 
	     		 doSearch();
	       	} 
		});
		
		jQuery("#table").datagrid({
			title:"公共费用明细",
			iconCls:'icon-zc',
			loadMsg:'正在加载数据，请稍后......',
			url:'<%=contextPath %>/springMVC/finance/listPageFinanceCommonDetail?is_all=1&has_finished=1',
			rownumbers:true,
			fitColumns:true,
			nowrap:false,
			idField:'id',
			frozenColumns:[[
			      {title:'主键',field:'id',hidden:true}
			]],
			columns:[[
				{title:'日期',field:'operation_time',width:100,align:'center'},
				{title:'申请人id',field:'user_id',width:100,align:'center',hidden:true},
				{title:'申请人',field:'user_name',width:100,align:'center'},
				{title:'所属公司',field:'name',width:200,align:'center'},
				{title:'确定承担部门',field:'is_all',width:100,align:'center',formatter:function(value,rowData,rowIndex){
					if(rowData.is_all == 0){
						return "确定";
					}
					return "不确定";
				}},
				{title:'费用科目',field:'type',width:100,align:'center'},
				{title:'承担部门',field:'dept_name',width:100,align:'center'},
				{title:'承担金额',field:'money',width:100,align:'center'},
				{title:'备注',field:'remark',width:100,align:'center'},
				{title:'查看凭证',field:'opMore',width:100,align:'center',formatter:function(value,rowData,rowIndex){
						var str="";
	                    	str+= "<input type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-details' title='详情' onclick=\"javascript:viewFC('"+rowData.id+"');\"/>";
	                    return str;
				}}
			]],
			pageSize:10,
			pageList : [10,50,100],  
			pagination:true,
			onLoadSuccess:function(rtJson){
				if(rtJson.rtState== '1')
				{
					$.messager.alert('提示',rtJson.rtMsrg);
				}
			}
		});
	});
	
	function viewFC(id){
		openDialogResize("<%=contextPath %>/springViews/finance/addOrEditFinanceCommons.jsp?isShow=1&id="+id,1000, 800);
	}
	
		function doSearch() {
			var start_time=jQuery('#start_time').datebox('getValue');  
			var end_time=jQuery('#end_time').datebox('getValue'); 
			var user_name=jQuery('#user_name').val();
			var company_id = $('#company_id').combotree('getValue');
			var type_id = $('#type_id').combotree('getValue');
			jQuery('#table').datagrid('load', {
				start_time:start_time,
				end_time:end_time,
				user_name:user_name,
				company_id:company_id,
				type_id:type_id
			});
		}
		function exportExcel()
		{
			var start_time=jQuery('#start_time').datebox('getValue');  
			var end_time=jQuery('#end_time').datebox('getValue'); 
			var user_name=encodeURIComponent(jQuery('#user_name').val());
			var company_id = $('#company_id').combotree('getValue');
			var type_id = $('#type_id').combotree('getValue');
			window.open('<%=contextPath%>/springMVC/excel/financeCommonsDetailExcel?is_all=1&has_finished=1&start_time='+start_time+'&end_time='+end_time+'&user_name='+user_name+'&company_id='+company_id+'&type_id='+type_id);
		}
	</script>
	</head>
	<body style="height:97%">
			<div id="table"  data-options="toolbar:'#tb',fit:true"></div>  
				<div id="tb" style="padding:3px;height:auto">
				<div style="float:left;">
			</div>
			<div align="right">
				开始时间：<input id="start_time" name="start_time" class="easyui-datebox" style="width:100px" />&nbsp;&nbsp;&nbsp;结束时间：<input id="end_time" name="end_time" class="easyui-datebox" style="width:100px"/>
				申请人：<input type="text" id="user_name" name="user_name"   style="width:100px">
				所属公司：<input type="text" id="company_id" name="company_id"   style="width:200px">
				费用科目：<input type="text" id="type_id" name="type_id"   style="width:200px">
				<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="doSearch();"></a>
				<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-excel',plain:true" onclick="exportExcel();"></a>
			</div>
		</div>
	</body>
</html>